﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Drawing;using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraEditors;
using DevExpress.XtraBars;
using System.Collections;
using DevExpress.XtraBars.Helpers;
using UI.Forms.ProReport;


namespace UI.Forms
{
    public partial class MainForm : XtraForm
    {
        public UserMgr frm1;
        public MainForm()
        {
            InitializeComponent();
            barManager1.ForceInitialize();
            SkinHelper.InitSkinPopupMenu(mPaintStyle);
         }

        private void Form1_Load(object sender, EventArgs e)
        {
            my.mainform = this;
            Nav frm = new Nav();
            frm.MdiParent = this;
            frm.CloseBox = false;
            sSecItem.Caption = my.emp_lite.EmpName;
            frm.Show();
            
        }

        private void iPower_ItemClick(object sender, ItemClickEventArgs e)
        {
            station frm = new station();
            frm.MdiParent = this;
            frm.Show();
        }

        private void barManager_Merge(object sender, BarManagerMergeEventArgs e)
        {
            if (e.ChildManager.Form is UserMgr)
            {
                Bar newBar = new Bar(barManager1);
                newBar.BarName = "DynamicBar";
                newBar.OptionsBar.Hidden = true;
                newBar.OptionsBar.UseWholeRow = false;
                Bar sourceBar = e.ChildManager.Bars["Tools"];

                newBar.DockStyle = BarDockStyle.Top;
                barManager1.Bars.Add(newBar);
                newBar.Merge(sourceBar);
                sourceBar.Visible = false;
            }
        }

        private void barManager_UnMerge(object sender, BarManagerMergeEventArgs e)
        {
            Bar newBar = barManager1.Bars["DynamicBar"];
            if (newBar != null)
                newBar.Dispose();
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (XtraMessageBox.Show("您确定要退出系统？", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                this.Dispose();
                Application.Exit();
            }
            else
            {
                e.Cancel = true;
            }
        }

        private void btn_商品类别_ItemClick(object sender, ItemClickEventArgs e)
        {
            goodsclass frm = new goodsclass();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btn_Warehouse_ItemClick(object sender, ItemClickEventArgs e)
        {
            Warehouse frm = new Warehouse();
            frm.MdiParent = this;
            frm.Show();
            
        }

        private void btn_shop_ItemClick(object sender, ItemClickEventArgs e)
        {
            shop frm = new shop();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btn_department_ItemClick(object sender, ItemClickEventArgs e)
        {
            Department frm = new Department();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btn_goodinfo_ItemClick(object sender, ItemClickEventArgs e)
        {
            goods frm = new goods();
            frm.MdiParent = this;
            frm.Show();
        }

        private void barButtonItem37_ItemClick(object sender, ItemClickEventArgs e)
        {
            CRM_Client frm = new CRM_Client();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btn_area_ItemClick(object sender, ItemClickEventArgs e)
        {
            Area frm = new Area();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btn_combo_ItemClick(object sender, ItemClickEventArgs e)
        {
            Combo frm = new Combo();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btn_CardIN_ItemClick(object sender, ItemClickEventArgs e)
        {
            CardINStore frm = new CardINStore();
            frm.MdiParent = this;
            frm.Show();
        }

        private void barButtonItem20_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (this.MdiChildren.Count(p => p.Text == "主控台") > 0)
            {
                this.MdiChildren[0].Show();
                this.MdiChildren[0].Activate();
            }
            else
            {
                Nav frm = new Nav();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void btn_GYS_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm("UI.Forms.CRM_GYS");
        }



        private void btn_BlankCardIN_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm(e.Item.Tag.ToString());
        }

        private void btn_cards_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm("UI.Forms.Cards");
        }

        private void MainForm_MaximumSizeChanged(object sender, EventArgs e)
        {
            UpdateSkinPainter(); 
        }

        private void MainForm_MinimumSizeChanged(object sender, EventArgs e)
        {
            UpdateSkinPainter(); 
        }

        private void btn_bank_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm("UI.Forms.bank");
        }

        private void btn_emp_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm("UI.Forms.empMgr");
        }

        private void iConfig_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btn_Station_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm("UI.Forms.station");
        }

        private void barButtonItem43_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btn_Crm_Contact_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm("UI.Forms.crm_contact");
        }

        private void btn_zftype_ItemClick(object sender, ItemClickEventArgs e)
        {
            Comm.openForm("UI.Forms.zftype");
        }
        /// <summary>
        /// 入库单产品明细
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bbProDel_ItemClick(object sender, ItemClickEventArgs e)
        {
            InBillnoDetail fm = new InBillnoDetail();
            fm.MdiParent = my.mainform;
            fm.Show();
        }
        /// <summary>
        /// 产品入库单汇总表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bbProBilCol_ItemClick(object sender, ItemClickEventArgs e)
        {
            InBillnoCollect fm = new InBillnoCollect();
            fm.MdiParent = my.mainform;
            fm.Show();
        }
        /// <summary>
        /// 产品入库汇总表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bbProDealCol_ItemClick(object sender, ItemClickEventArgs e)
        {
            InProCollect fm = new InProCollect();
            fm.MdiParent = my.mainform;
            fm.Show();
        }
        /// <summary>
        /// 供应商入库单汇总表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bbProBilSup_ItemClick(object sender, ItemClickEventArgs e)
        {
            InSupBilCollect fm = new InSupBilCollect();
            fm.MdiParent = my.mainform;
            fm.Show();
        }
        /// <summary>
        /// 供应商入库汇总表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem36_ItemClick(object sender, ItemClickEventArgs e)
        {
            InSupplierCollect fm = new InSupplierCollect();
            fm.MdiParent = my.mainform;
            fm.Show();
        }











    }
}